<template>
	<view class="content">
		<!-- 广告图 -->
		<banner :inset='con'></banner>

		<!-- 首页分类 -->
		<scroll-view :scroll-x="true" style="width: 100%;">
			<view class="uni-flex uni-center m-2" style="width: 110%;padding-right: 40rpx;">
				<view class="span-4" style="float: left;" @click="tz(item.path)" v-for="(item,index) in navs"
					:key="index">
					<image :src="item.imgs" mode=""></image>
					<text class="text">{{item.title}}</text>
				</view>
			</view>
		</scroll-view>
		<!-- 首页签到 -->
		<view class="qiandan m-2" @click="open_init()">
			<image style="height: 193upx;" src="../../static/banner/qd.png" mode=""></image>
		</view> 
		<!-- 弹出框 -->
		<uni-popup class="popss" ref="popup" :mask-click="true">
			<view class="popup-content">
				<view class="posis">
					<view class="posi">
						<view class="qd_lx">
							<text>{{qd}}</text>
						</view>
						<view class="zhidao" @tap="qdxq()">查看详情</view>
					</view>
					<view class="guanbi" @click="guanbis">
						<uni-icons type="closeempty" size="30" color="#ffffff"></uni-icons>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 轮播 -->
		<lunbo></lunbo>
		<!-- 政策方针 -->
		<zhengce v-if="hackReset"></zhengce>
	</view>
</template>

<script>
	// import {mapState,mapMutations,forcedLogin} from 'vuex'
	import push from "@/common/push.js"
	export default {
		// computed:mapState(['hasLogin','uerInfo']),
		data() {
			var con = '/static/banner/banner.png'
			return {
				hackReset: true,
				show: false,
				title: 'Hello',
				con: con,
				qd: '',
				navs: [{
						imgs: "../../static/banner/ban1.png",
						title: '全景思政',
						path: '/pages/index/ziye/ziye'
					},
					{
						imgs: "../../static/banner/ban2.png",
						title: 'VR体验',
						path: '/pages/index/ziye/vr'
					},
					{
						imgs: "../../static/banner/ban3.png",
						title: '教学资源',
						path: './jiaoxue/jiaoxuefenlei'
					},
					{
						imgs: "../../static/banner/ban5.png",
						title: '实践中心',
						path: '/pages/index/renwu/renwu'
					},
					{
						imgs: "../../static/banner/ban7.png",
						title: '作业中心',
						path: '/pages/index/homework/homework'
					},
					{
						imgs: "../../static/banner/ban4.png",
						title: '方针政策',
						path: '/pages/index/fangzhen/fangzhen'
					},
				]
			}
		},
		created() {},
		onHide() {
			console.log('onHide...')
			this.hackReset = false;
			this.$nextTick(() => {
				this.hackReset = true;
			})
		},
		onShow() {


			// this.token = uni.getStorageSync('token')
			// if(this.token == ''){
			// 	uni.reLaunch({
			// 		// url:'/pages/index/logo/logo'
			// 	})
			// }else{
			// 	uni.navigateTo({
			// 		url:'/pages/index/index'
			// 	});
			// }
		},
		onLoad() {
			// plus.runtime.openURL( 'mindclass://',function(res){
			// 	console.log(res);
			// },'cn.puyunwl.mindclass');
			// document.addEventListener('plusready', function(){
			// 页面加载时触发

			var pinf = plus.push.getClientInfo();
			var cid = pinf.clientid; //客户端标识
			// console.log(cid);
			this.updateCid(cid);
			// }, false );
			//首页
			// console.log("===---===");
			// plus.push.getClientInfoAsync((info) => {
			// cid = info.clientid;
			// console.log(cid);
			// }, err => {
			// });
		},
		methods: {
			//判断用户是否打开通知
			pushIsOpen() {
				var id = push.isOn();
				// console.log("push is "+id);
				if (!push.isOn()) {
					//android
					push.on();
					//ios
					// push.iosSetting();
				}

			},
			//更新用户cid
			updateCid(cid) {
				let that = this;
				that.pyReq(that.$http.updateCid, {
					cid: cid
				}, function(res) {

				})
			},
			// ...mapMutations(['logout']),
			// bindLogin() {
			// 	if (this.hasLogin) {
			// 		this.logout()
			// 	} else {
			// 		uni.navigateTo({
			// 			url: './logo/logo'
			// 		})
			// 	}
			// },	
			open_init(index) {
				var that = this;
				that.type = index;
				that.pyReq(that.$http.signin, {}, function(res) {
					that.$refs.popup.open('center')
					console.log(res.msg);
					that.qd = res.msg
				});
				// let headers={
				// 	  'content-type': 'application/x-www-form-urlencoded',
				// 	  'token': uni.getStorageSync('token')
				// }
				//  uni.request({
				// 	  url: that.$http.signin,
				// 	  method: 'POST',
				// 	  header:headers,
				// 	  success: (res)=>{
				// 		  console.log(res)
				// 		  this.$refs.popup.open('center')
				// 		  that.qd = res.data.msg
				// 	  },
				// 	  fail: (err)=>{
				// 		  console.log(err)
				// 	  }
				// })  
			},
			close() {
				this.$refs.popup.close()
			},
			guanbis() {
				this.close()
			},
			qdxq() {
				this.close()
				uni.navigateTo({
					url: '../my/qiandao'
				})
			},
			//导航
			tz(url) {
				if (uni.getStorageSync("cokei") == 1) {
					if (url == "/pages/index/renwu/renwu") {
						url = '/pages/index/renwu/renwuxue'
						uni.navigateTo({
							url
						})
					} else {
						url = url + "?showMovie=1"
						uni.navigateTo({
							url
						})
					}
				} else {
					url = url + "?showMovie=1"
					uni.navigateTo({
						url
					})
				}
				console.log(url)
			}
		}
	}
</script>

<style>
	.zhidao {
		font-size: 28upx;
		margin-top: 50upx;
		text-align: center;
		background-color: rgb(179, 22, 16);
		line-height: 88upx;
		color: #FFFFFF;
	}

	.guanbi {
		border: 2upx solid #FFFFFF;
		width: 60upx;
		height: 60upx;
		margin: 0 auto;
		margin-top: 40upx;
		border-radius: 50%;
		text-align: center;
	}

	.qd_lx {
		width: 320upx;
		height: 48upx;
		background-color: #FF9103;
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 443upx;
		border-radius: 30upx;
	}

	.posi {
		width: 495upx;
		height: 625upx;
		background: #FFFFFF;
		border-radius: 20upx;
		overflow: hidden;
		background-image: url(/static/qdbj.png);
		background-position: center;
		background-size: 100% 100%;
	}

	.span-4 {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.span-4 image {
		width: 82upx;
		height: 82upx;
	}

	.tb_ys {
		width: 80upx;
		height: 80upx;
		border-radius: 50%;
		background-color: #B31610;
		justify-content: center;
	}

	.tb_ys image {
		width: 80upx;
		height: 80upx;
	}

	.span-4 text {
		font-size: 26upx;
		padding-top: 20upx;
	}

	/* 颠倒 */
</style>
